# 构建
# FROM hub.yiducloud.cn/library/node:14.16.0-alpine3.12 AS build
FROM hub.yiducloud.cn/docker/node:22.10.24 AS build
# FROM node:11.12.0 AS build
WORKDIR /build
COPY . .
RUN time npm ci && time npm run vbuild

# The base image
# FROM dockerhub.m.com/ep/nginx:v1.3
FROM hub.yiducloud.cn/docker/nginx:22.10.24

# Install register
# RUN pip install -i http://devpi.intra.yiducloud.cn/root/yiducloud/+simple/ --trusted-host devpi.intra.yiducloud.cn register>=17.0.3

# Add nginx config, replace the default one
# RUN rm /etc/nginx/sites-available/default
# ADD NGINX /etc/nginx/sites-available/default
RUN rm /etc/nginx/conf.d/default.conf
COPY NGINX /etc/nginx/conf.d/default.conf


# Copy source code, NOTE, the directory 'src' itself will be not copied be it's content
COPY --from=build /build/dist  /var/www/default/
# Install by fpm
#RUN cd /var/www/default/ && fpm install && fpm m .
# NOTE, this port should be equals to the port in nginx config
ENV PAAS_SERVICE_PORTS=80

# ADD start script
ADD start.sh /

ENTRYPOINT bash /start.sh
